package aod.android.com.bernay.message.fragment;

import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.MultiItemTypeAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import org.w3c.dom.Text;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import aod.android.com.bernay.R;
import aod.android.com.bernay.base.BernayBaseFragment;
import aod.android.com.bernay.http.BernayApi;
import aod.android.com.bernay.http.BernayCallback;
import aod.android.com.bernay.message.activity.DeviceMsgActivity;
import aod.android.com.bernay.message.module.DeviceMessageBean;
import chen.lion.hilib.util.LogUtils;
import chen.lion.hilib.view.bind.HiView;

/**
 * @author crated by zhixianuanyang on 2019/4/4 15:29
 * @Email jamesKing0812@gmail.com
 */
public class DeviceMessageFragment extends BernayBaseFragment implements View.OnClickListener {

    @HiView(R.id.rl_gravity)
    RelativeLayout mGravity;

    @HiView(R.id.rl_powerNews)
    RelativeLayout mPowerNews;


    @HiView(R.id.rl_ambient)
    RelativeLayout mAmbient;

    @HiView(R.id.rl_intercom)
    RelativeLayout mIntercom;

    @HiView(R.id.rl_equipment)
    RelativeLayout mEquipment;

    @HiView(R.id.tv_gravity)
    TextView tvGravity;

    @HiView(R.id.tv_power)
    TextView tvPower;

    @HiView(R.id.tv_ambient)
    TextView tvAmbient;

    @HiView(R.id.tv_intercom)
    TextView tvIntercom;

    @HiView(R.id.tv_equipment)
    TextView tvEquipment;

    //页
    private static final int pageIndex = 1;
    //一页条数
    private static final int pageSize = 10;
    //2是设备消息
    private static final int MSG_DEVICE_TYPE = 2;

    @Override
    protected int initLayout() {
        return R.layout.fragment_device_message;
    }

    @Override
    protected void initData() {
        mGravity.setOnClickListener(this);
        mPowerNews.setOnClickListener(this);
        mAmbient.setOnClickListener(this);
        mIntercom.setOnClickListener(this);
        mEquipment.setOnClickListener(this);

        tvGravity.setVisibility(View.GONE);
        tvPower.setText("2");
        tvAmbient.setVisibility(View.GONE);
        tvIntercom.setText("4");
        tvEquipment.setVisibility(View.GONE);
    }


    /**
     * 获取用户信息
     */
    public void deviceMsgList() {
        BernayApi.http().deviceMsgList(pageIndex, pageSize, MSG_DEVICE_TYPE, new BernayCallback() {
            @Override
            public void onJsonData(String json) {
                LogUtils.e(json);
            }

            @Override
            public void onHttpFailure(IOException e) {

            }
        });
    }

    @Override
    public void onClick(View v) {
        Bundle bundle = new Bundle();
        switch (v.getId()){
            case R.id.rl_gravity:
                bundle.putString("deviceMsg",getString(R.string.gravity_message));
                goActivity(DeviceMsgActivity.class,bundle);
                break;
            case R.id.rl_powerNews:
                bundle.putString("deviceMsg",getString(R.string.power_shortage_news));
                goActivity(DeviceMsgActivity.class,bundle);
                break;
            case R.id.rl_ambient:
                bundle.putString("deviceMsg",getString(R.string.ambient_temperature));
                goActivity(DeviceMsgActivity.class,bundle);
                break;
            case R.id.rl_intercom:
                bundle.putString("deviceMsg",getString(R.string.intercom_message));
                goActivity(DeviceMsgActivity.class,bundle);
                break;
            case R.id.rl_equipment:
                bundle.putString("deviceMsg",getString(R.string.equipment_message));
                goActivity(DeviceMsgActivity.class,bundle);
                break;
                default:
                    break;
        }
    }
}
